<template>
	<view>
		<uni-search-bar placeholder="搜索电影" @confirm="shou" @cancel="getlist()" @clear="getlist()"></uni-search-bar>
		<u-swiper :height="250" :list="lun" :effect3d="true" :interval="3000" @click="click"></u-swiper>
		<uni-group title="电影列表">
			<uni-card @click="toinde(item.id)" v-for="(item,index) in list" :thumbnail="base+item.cover" :title="item.name">
				<view>上映时间：{{item.playDate}}</view>
				<view>时长：{{item.duration}}分钟</view>
			</uni-card>
			<button type="warn" @click="tugeng">查看更多</button>
		</uni-group>
	</view>
</template>

<script>
	import api from 'commer/apiURL.js'
	export default {
		data() {
			return {
				base: api.baseurl,
				lun:[],
				list:[],
				tt:true,
			}
		},
		onLoad() {
			this.getlun()
			this.getlist()
		},
		methods: {
			toinde(id){
				uni.navigateTo({
					url:'xianq?id='+id
				})
			},
			shou(e){
				this.list = this.list.filter((item)=>{
					if(item.name.indexOf(e.value) >= 0){
						return item
					}
				})
			},
			tugeng(){
				this.getlist2()
			},
			getlun() {
				this.$get(this.base + '/prod-api/api/movie/rotation/list').then((res) => {
					res.rows.forEach((item) => {
						this.lun.push({
							image: this.base + item.advImg
						})
					})
				})
			},
			getlist() {
				this.$get(this.base + '/prod-api/api/movie/film/list').then((res) => {
					this.list = res.rows.slice(0,5)
					this.tt = true
				})
			},
			getlist2() {
				this.$get(this.base + '/prod-api/api/movie/film/list').then((res) => {
					this.tt = false
					this.list = res.rows
				})
			}
		}
	}
</script>

<style>

</style>
